package org.example.dao.impl;

import org.example.dao.SoftDao;
import org.example.entity.Soft;
import org.example.dao.DBUtil;

import java.sql.*;
import java.util.ArrayList;
import java.util.List;

public class SoftDAOImpl implements SoftDao {

    @Override
    public List<Soft> getAllSofts() {
        List<Soft> softs = new ArrayList<>();
        String sql = "SELECT * FROM soft";

        try (Connection conn = DBUtil.getConn();
             Statement stmt = conn.createStatement();
             ResultSet rs = stmt.executeQuery(sql)) {

            while (rs.next()) {
                Soft soft = new Soft();
                soft.setSoft_id(rs.getInt("soft_id"));
                soft.setSoft_name(rs.getString("soft_name"));
                soft.setDept_id(rs.getInt("dept_id"));
                soft.setUse_id(rs.getInt("use_id"));
                soft.setHire_date(rs.getDate("hire_date"));
                softs.add(soft);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return softs;
    }

    @Override
    public Soft getSoftById(int id) {
        return null;
    }

    @Override
    public void addSoft(Soft soft) {

    }

    @Override
    public void updateSoft(Soft soft) {

    }

    @Override
    public void deleteSoft(int id) {

    }

}